//
//  RecSearchTableViewCell.m
//  TravelEveryDay
//
//  Created by dlios on 15-10-21.
//  Copyright (c) 2015年 com.lanou3g. All rights reserved.
//

#import "RecSearchTableViewCell.h"

@implementation RecSearchTableViewCell
-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        _image = [[UIImageView alloc] initWithFrame:CGRectMake(10 * WIDTH, 10 * HEIGHT, 130 * WIDTH, 150 * HEIGHT)];
        [self.contentView addSubview:_image];
        
        _titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(150 * WIDTH, 10 * HEIGHT, 220 * WIDTH, 40 * HEIGHT)];
        _titleLabel.font = [UIFont boldSystemFontOfSize:20.];
        [self.contentView addSubview:_titleLabel];
        
        _timeLabel = [[UILabel alloc] initWithFrame:CGRectMake(150 * WIDTH, 60 * HEIGHT, 150 * WIDTH, 30 * HEIGHT)];
        _timeLabel.font = [UIFont systemFontOfSize:16
                           ];
        [self.contentView addSubview:_timeLabel];
        
        _dayCountLabel = [[UILabel alloc] initWithFrame:CGRectMake(150 * WIDTH, 90 * HEIGHT, 100 * WIDTH, 30 * HEIGHT)];
        _dayCountLabel.font = [UIFont systemFontOfSize:16.];
        [self.contentView addSubview:_dayCountLabel];
        
        _infoLabel = [[UILabel alloc] initWithFrame:CGRectMake(150 * WIDTH, 130 * HEIGHT, 220 * WIDTH, 30 * HEIGHT)];
        _infoLabel.font = [UIFont systemFontOfSize:14.];
        _infoLabel.alpha = 0.6;
        [self.contentView addSubview:_infoLabel];
    }
    return self;
}
-(void)getData:(RecSearchModel *)model
{
    [_image sd_setImageWithURL:[NSURL URLWithString:model.cover_image] placeholderImage:PLACEHOLDERIMAGE];
    
    
    //日期转换
    NSDate *date = [NSDate dateWithTimeIntervalSince1970:model.date_added.integerValue];
    NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
    formatter.dateFormat = @"YYYY.MM.dd";
    NSString *str = [formatter stringFromDate:date];
    _timeLabel.text = str;
    
    _dayCountLabel.text = [NSString stringWithFormat:@"%@天",model.day_count.stringValue];
    
    _infoLabel.text = [NSString stringWithFormat:@"足迹:%@  评论:%@",model.waypoints,model.recommendations];
    

    
}
- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
